/*************************************************************************
 *                                                                       *
 * This file is part of the DogosFrame distribution.  For full copyright *
 * information, see COPYRIGHT and COPYING.LESSER.                        *
 *                                                                       *
 * Author:           sqbang                                              *
 * Email:            sqbang@ustc.edu                                     *
 *                                                                       *
 *************************************************************************/

#ifndef DOGOS_include_COMMON_base_Process_h
#define DOGOS_include_COMMON_base_Process_h

#include "DogosConfig.h"

//COMMON headers
#include "COMMON/base/Common.h"

namespace DOGOS
{

//forward declarations
class InputDatabase;

/**
 * the interface class for process simulator
 */
class Process
{
public:

    /**
     * @brief constructor function
     * @param file_name is the file when run command line such as "$FreeMAPs -f setup.dat"
     * @note that we do NOT use file_name directly, a temporary file of
     * ".file_name.index" will be used to supported the macro
     * of file include.and the index is a number of 6 digits.
     * all command of #include<file> will be expanded on the location where it lies.
     *
     * file_type indicate the filename is setup file or script file.
     *  "setup" -- setup file
     *  "script" -- script file, used to generate setup file.
     */
    explicit
    Process (
        const std::string& file_name,
        const std::string& file_type);

    virtual
    ~Process();

public:

    /**
     * @brief do process step by step
     * the step is as following:
     *  -# build the geom and mesh
     *  -# do simulation
     */
    void
    solve();

    /**
     * do something before time loop start.
     */
    virtual void
    preprocess();

    /**
     * do something after time loop end.
     */
    virtual void
    postprecess();

private:

    /*
     * read information from file and build class CommonInfo
     */
    void
    get_from_input(
        const InputDatabase* top_input_db,
        const bool is_from_restart);

private:

    DISALLOW_COPY_AND_ASSIGN (Process);
};

}

#include "COMMON/smlt/Process.inl"

#endif
